package com.baizhi.day02;

public class CarTest {
    public static void main(String[] args) {
        //无参构造创建对象
        Car c1 = new Car();
        c1.brand = "奔驰";
        c1.color = "蓝色";
        c1.price = 300000;
        c1.run();

        //含参构造创建对象并初始化
        Car c2 = new Car("奥拓","黑色",150000);
        c2.run();
    }
}

/**
 * 表示车的类
 */
class Car{

    String brand;
    String color;
    double price;

    //无参构造
    public Car(){}

    //含参构造
    public Car(String b,String c,double p){
        brand = b;
        color = c;
        price = p;

    }

    void run(){
        System.out.println("车跑起来了");
    }
}
